<?php

namespace app\common\traits;

/**
 * 远端相关信息
 * Trait RemoteTrait
 * @package app\common\traits
 * @author ^2_3^王尔贝
 */
trait RemoteTrait
{
    /**
     * 远端IP
     * @return mixed|string
     * @author cenyebao^2_3^
     * @email 1142733640@qq.com
     */
    public function getRealIP()
    {
        $forwarded = request()->header("x-forwarded-for");
        if($forwarded) {
            $ip = explode(',',$forwarded)[0];
        }else{
            $ip = request()->ip();
        }
        return $ip;
    }

}